package com.zdkj.subway.check.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zdkj.common.core.util.R;
import com.zdkj.subway.check.entity.*;
import com.zdkj.subway.check.mapper.*;
import com.zdkj.subway.check.service.SwAuCenterConductorAmountDifferenceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.zdkj.subway.check.util.DateFormat;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

@Service
@Slf4j
public class SwAuCenterConductorAmountDifferenceServiceImpl extends ServiceImpl<SwAuCenterConductorAmountDifferenceMapper,SwAuCenterConductorAmountDifference> implements SwAuCenterConductorAmountDifferenceService {

    @Resource
    private SwStInputPassengerWorkTicketMapper swStInputPassengerWorkTicketMapper;
    @Resource
    private SwAuConductorShortMapper swAuConductorShortMapper;
    @Resource
    SwStConductorSettleRepairMapper swStConductorSettleRepairMapper;
    @Resource
    SwStTicketPettyAddMapper swStTicketPettyAddMapper;
    @Resource
    private SwStInputPassengerWorkMapper swStInputPassengerWorkMapper;
    @Resource
    private SwStInputPassengerWorkOtherMapper swStInputPassengerWorkOtherMapper;
    @Resource
    private SwStMarketingTicketMapper swStMarketingTicketMapper;
    @Resource
    private SwStBomIncomeSettleMapper swStBomIncomeSettleMapper;
    @Resource
    private SwAuCenterConductorAmountDifferenceMapper swAuCenterConductorAmountDifferenceMapper;
    @Resource
    private SwStTicketInformationCheckMapper swStTicketInformationCheckMapper;
    @Resource
    private SwAuConductorToBeCheckedMapper swAuConductorToBeCheckedMapper;
    @Resource
    private SwAuConductorNoticeMapper swAuConductorNoticeMapper;


    /**
     * 作废BOM数据
     * @param param
     * @return
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public R invalidTvmData(Map<String,String> param) {
        String lineCode = param.get("lineCode");
        String stationCode = param.get("stationCode");
        String conductorJobNo = param.get("conductorJobNo");
        String bomCode = param.get("bomCode");
        String recordTime = param.get("recordTime");
		String deviceOperateNum = param.get("equipmentNumber"); //获取设备操作号
        String delFlag = "0";
        //判断售票员是否有乘客事务非即时退换票已领取无效票操作，有则不允许作废
        LambdaQueryWrapper<SwStInputPassengerWorkTicket> inputPassengerWorkTicketWrapper = new LambdaQueryWrapper<>();
        inputPassengerWorkTicketWrapper.eq(SwStInputPassengerWorkTicket::getLineCode,lineCode)
                .eq(SwStInputPassengerWorkTicket::getStationCode,stationCode)
                .eq(SwStInputPassengerWorkTicket::getHandlePersonCode,conductorJobNo)
			    .eq(SwStInputPassengerWorkTicket::getDeviceOperateNum,deviceOperateNum)  //20240311 增加设备操作号
                .eq(SwStInputPassengerWorkTicket::getHandleTime,recordTime)
                .eq(SwStInputPassengerWorkTicket::getDelFlag,delFlag);
        List<SwStInputPassengerWorkTicket> inputPassengerWorTicketkList = swStInputPassengerWorkTicketMapper.selectList(inputPassengerWorkTicketWrapper);
        if(CollectionUtil.isNotEmpty(inputPassengerWorTicketkList)){
            for (SwStInputPassengerWorkTicket item : inputPassengerWorTicketkList) {
                if(!"0".equals(item.getInvalidTicketStatus())){
                    return R.failed("该售票员数据存在乘客事务非即时退换票已领取无效票，不允许作废");
                }
            }
        }
        //判断售票员是否有补款成功的数据，有则不允许作废
        LambdaQueryWrapper<SwAuConductorShort> conductorShortWrapper = new LambdaQueryWrapper<>();
        conductorShortWrapper.eq(SwAuConductorShort::getLineCode,lineCode)
                .eq(SwAuConductorShort::getStationCode,stationCode)
                .eq(SwAuConductorShort::getConductorPersonCode,conductorJobNo)
			    .eq(SwAuConductorShort::getEquipmentNumber, deviceOperateNum)  //20240311 增加设备操作号	
                .eq(SwAuConductorShort::getCheckTime,recordTime)
                .eq(SwAuConductorShort::getDelFlag,delFlag);
        List<SwAuConductorShort> conductorShortList = swAuConductorShortMapper.selectList(conductorShortWrapper);
        if(CollectionUtil.isNotEmpty(conductorShortList)){
            for (SwAuConductorShort item : conductorShortList) {
                if(item.getIsSupPayment()==3){
                    return R.failed("该售票员数据存在已补款操作，不允许作废");
                }
            }
        }
        //作废售票员日结算数据
        LambdaQueryWrapper<SwStConductorSettle> conductorSettleWrapper = new LambdaQueryWrapper<>();
        conductorSettleWrapper.eq(SwStConductorSettle::getLineCode, lineCode)
                .eq(SwStConductorSettle::getStationCode, stationCode)
                .eq(SwStConductorSettle::getConductorJobNo, conductorJobNo)
			    .eq(SwStConductorSettle::getDeviceOperateNum, deviceOperateNum)  //20240311 增加设备操作号			
                .eq(SwStConductorSettle::getBomCode, bomCode)
                .eq(SwStConductorSettle::getSettleTime, recordTime)
                .eq(SwStConductorSettle::getDelFlag, delFlag);
        SwStConductorSettle swStConductorSettle = new SwStConductorSettle();
        swStConductorSettle.setDelFlag("1");
        swStConductorSettle.setInvalidStatus("1");
        swStConductorSettleRepairMapper.update(swStConductorSettle, conductorSettleWrapper);
        //作废车站配票与配备用金
        LambdaQueryWrapper<SwStTicketPettyAdd> ticketPettyAddWrapper = new LambdaQueryWrapper<>();
        ticketPettyAddWrapper.eq(SwStTicketPettyAdd::getLineCode, lineCode)
                .eq(SwStTicketPettyAdd::getStationCode, stationCode)
                .eq(SwStTicketPettyAdd::getNsJobNo, conductorJobNo)
			    .eq(SwStTicketPettyAdd::getDeviceOperateNum, deviceOperateNum)  //20240311 增加设备操作号
                .likeRight(SwStTicketPettyAdd::getWorkingStartTime, recordTime)
                .eq(SwStTicketPettyAdd::getDelFlag, delFlag);
        SwStTicketPettyAdd swStTicketPettyAdd = new SwStTicketPettyAdd();
        swStTicketPettyAdd.setDelFlag("1");
        swStTicketPettyAdd.setInvalidStatus("1");
        swStTicketPettyAddMapper.update(swStTicketPettyAdd, ticketPettyAddWrapper);
        //作废乘客事务数据录入数据、乘客事务审核数据
        LambdaQueryWrapper<SwStInputPassengerWork> inputPassengerWorkWrapper = new LambdaQueryWrapper<>();
        inputPassengerWorkWrapper.eq(SwStInputPassengerWork::getLineCode, lineCode)
                .eq(SwStInputPassengerWork::getStationCode, stationCode)
                .eq(SwStInputPassengerWork::getConductorCode, conductorJobNo)
			    .eq(SwStInputPassengerWork::getDeviceOperateNum, deviceOperateNum)  //20240311 增加设备操作号
                //.eq(SwStInputPassengerWork::getBomCode, bomCode)  //去掉BOM编号  20240630
                .eq(SwStInputPassengerWork::getWorkDate, recordTime)
                .eq(SwStInputPassengerWork::getDelFlag, delFlag);
        SwStInputPassengerWork swStInputPassengerWork = new SwStInputPassengerWork();
        swStInputPassengerWork.setDelFlag("1");
        swStInputPassengerWork.setInvalidStatus("1");
        swStInputPassengerWorkMapper.update(swStInputPassengerWork, inputPassengerWorkWrapper);
        //作废其他相关数据录入
        LambdaQueryWrapper<SwStInputPassengerWorkOther> inputPassengerWorkOtherWrapper = new LambdaQueryWrapper<>();
        inputPassengerWorkOtherWrapper.eq(SwStInputPassengerWorkOther::getLineCode, lineCode)
                .eq(SwStInputPassengerWorkOther::getStationCode, stationCode)
                .eq(SwStInputPassengerWorkOther::getConductorCode, conductorJobNo)
                .eq(SwStInputPassengerWorkOther::getDeviceOperateNum, deviceOperateNum)  //20240311 增加设备操作号
                .apply("DATE_FORMAT(input_time,'%Y-%m-%d') = '"+recordTime+"'")
                .eq(SwStInputPassengerWorkOther::getDelFlag, delFlag);
        SwStInputPassengerWorkOther swStInputPassengerWorkOther = new SwStInputPassengerWorkOther();
        swStInputPassengerWorkOther.setDelFlag("1");
        swStInputPassengerWorkOther.setInvalidStatus("1");
        swStInputPassengerWorkOtherMapper.update(swStInputPassengerWorkOther, inputPassengerWorkOtherWrapper);
        //作废乘客事务退换票 //只作废即时退换的数据
        LambdaQueryWrapper<SwStInputPassengerWorkTicket> passengerWorkWrapper = new LambdaQueryWrapper<>();
        passengerWorkWrapper.eq(SwStInputPassengerWorkTicket::getLineCode, lineCode)
                .eq(SwStInputPassengerWorkTicket::getStationCode, stationCode)
                .eq(SwStInputPassengerWorkTicket::getOperationType, "0")
                .eq(SwStInputPassengerWorkTicket::getConductorCode, conductorJobNo)
			    .eq(SwStInputPassengerWorkTicket::getDeviceOperateNum, deviceOperateNum)  //20240311 增加设备操作号
                .apply("DATE_FORMAT(HANDLE_TIME,'%Y-%m-%d') = '"+recordTime+"'")
                .eq(SwStInputPassengerWorkTicket::getDelFlag, delFlag);
        SwStInputPassengerWorkTicket passengerWorkTicket = new SwStInputPassengerWorkTicket();
        passengerWorkTicket.setDelFlag("1");
        passengerWorkTicket.setInvalidStatus("1");
        swStInputPassengerWorkTicketMapper.update(passengerWorkTicket, passengerWorkWrapper);
        //作废营销车票数据、营销车票数据审核数据
        LambdaQueryWrapper<SwStMarketingTicket> marketingTicketWrapper = new LambdaQueryWrapper<>();
        marketingTicketWrapper.eq(SwStMarketingTicket::getLineCode, lineCode)
                .eq(SwStMarketingTicket::getStationCode, stationCode)
                .eq(SwStMarketingTicket::getConductorJobNo, conductorJobNo)
			    .eq(SwStMarketingTicket::getDeviceOperateNum, deviceOperateNum)  //20240311 增加设备操作号
                //.eq(SwStMarketingTicket::getBomCode, bomCode) //去掉BOM编号  20240630
                .eq(SwStMarketingTicket::getOpertorTime, recordTime)
                .eq(SwStMarketingTicket::getDelFlag, delFlag);
        SwStMarketingTicket swStMarketingTicket = new SwStMarketingTicket();
        swStMarketingTicket.setDelFlag("1");
        swStMarketingTicket.setInvalidStatus("1");
        swStMarketingTicketMapper.update(swStMarketingTicket, marketingTicketWrapper);
        //作废BOM结算已提交主页数据
        LambdaQueryWrapper<SwStBomIncomeSettle> bomIncomeSettleWrapper = new LambdaQueryWrapper<>();
        bomIncomeSettleWrapper.eq(SwStBomIncomeSettle::getLineCode, lineCode)
                .eq(SwStBomIncomeSettle::getStationCode, stationCode)
                .eq(SwStBomIncomeSettle::getConductorJobNo, conductorJobNo)
			    .eq(SwStBomIncomeSettle::getDeviceOperatorNum, deviceOperateNum)  //20240311 增加设备操作号
                .eq(SwStBomIncomeSettle::getRecordTime, recordTime)
                .eq(SwStBomIncomeSettle::getDelFlag, delFlag);
        SwStBomIncomeSettle swStTvmIncomeSettle = new SwStBomIncomeSettle();
        swStTvmIncomeSettle.setDelFlag("1");
        swStTvmIncomeSettle.setInvalidStatus("1");
        swStBomIncomeSettleMapper.update(swStTvmIncomeSettle, bomIncomeSettleWrapper);
        //作废售票员票款差异审核数据
        LambdaQueryWrapper<SwAuCenterConductorAmountDifference> conductorAmountDifferenceWrapper = new LambdaQueryWrapper<>();
        conductorAmountDifferenceWrapper.eq(SwAuCenterConductorAmountDifference::getLineCode, lineCode)
                .eq(SwAuCenterConductorAmountDifference::getStationCode, stationCode)
                .eq(SwAuCenterConductorAmountDifference::getConductorJobNo, conductorJobNo)
			    .eq(SwAuCenterConductorAmountDifference::getEquipmentNumber, deviceOperateNum)  //20240311 增加设备操作号			
                .eq(SwAuCenterConductorAmountDifference::getBomCode, bomCode)
                .eq(SwAuCenterConductorAmountDifference::getRecordTime, recordTime)
                .eq(SwAuCenterConductorAmountDifference::getDelFlag, delFlag);
        SwAuCenterConductorAmountDifference conductorAmountDifference = new SwAuCenterConductorAmountDifference();
        conductorAmountDifference.setDelFlag("1");
        conductorAmountDifference.setInvalidStatus("1");
        swAuCenterConductorAmountDifferenceMapper.update(conductorAmountDifference, conductorAmountDifferenceWrapper);
        //作废票卡信息查询数据
		/*  20240311 去掉票卡信息查询功能
        LambdaQueryWrapper<SwStTicketInformationCheck> ticketInformationCheckWrapper = new LambdaQueryWrapper<>();
        ticketInformationCheckWrapper.eq(SwStTicketInformationCheck::getSubmitLineCode, lineCode)
                .eq(SwStTicketInformationCheck::getSubmitStationCode, stationCode)
                .eq(SwStTicketInformationCheck::getInputPersonCode, conductorJobNo)
                .apply("DATE_FORMAT(input_time,'%Y-%m-%d') = '"+recordTime+"'")
                .eq(SwStTicketInformationCheck::getDelFlag, delFlag);
        SwStTicketInformationCheck ticketInformationCheck = new SwStTicketInformationCheck();
        ticketInformationCheck.setDelFlag("1");
        ticketInformationCheck.setInvalidStatus("1");
        swStTicketInformationCheckMapper.update(ticketInformationCheck, ticketInformationCheckWrapper);
		*/
        //作废售票员票款差异待协查数据
        LambdaQueryWrapper<SwAuConductorToBeChecked> conductorToBeCheckedWrapper = new LambdaQueryWrapper<>();
        conductorToBeCheckedWrapper.eq(SwAuConductorToBeChecked::getLineCode, lineCode)
                .eq(SwAuConductorToBeChecked::getStationCode, stationCode)
                .eq(SwAuConductorToBeChecked::getConductorPersonCode, conductorJobNo)
			    .eq(SwAuConductorToBeChecked::getEquipmentNumber, deviceOperateNum)  //20240311 增加设备操作号	
                .eq(SwAuConductorToBeChecked::getBomCode, bomCode)
                .eq(SwAuConductorToBeChecked::getRecordTime, recordTime)
                .eq(SwAuConductorToBeChecked::getDelFlag, delFlag);
        SwAuConductorToBeChecked conductorToBeChecked = new SwAuConductorToBeChecked();
        conductorToBeChecked.setDelFlag("1");
        conductorToBeChecked.setInvalidStatus("1");
        swAuConductorToBeCheckedMapper.update(conductorToBeChecked, conductorToBeCheckedWrapper);
        //作废售票员票款差异确认通知数据
        LambdaQueryWrapper<SwAuConductorNotice> conductorNoticeWrapper = new LambdaQueryWrapper<>();
        conductorNoticeWrapper.eq(SwAuConductorNotice::getLineCode, lineCode)
                .eq(SwAuConductorNotice::getStationCode, stationCode)
                .eq(SwAuConductorNotice::getConductorPersonCode, conductorJobNo)
			    .eq(SwAuConductorNotice::getEquipmentNumber, deviceOperateNum)  //20240311 增加设备操作号	
                .eq(SwAuConductorNotice::getBomCode, bomCode)
                .eq(SwAuConductorNotice::getRecordTime, recordTime)
                .eq(SwAuConductorNotice::getDelFlag, delFlag);
        SwAuConductorNotice swAuConductorNotice = new SwAuConductorNotice();
        swAuConductorNotice.setDelFlag("1");
        swAuConductorNotice.setInvalidStatus("1");
        swAuConductorNoticeMapper.update(swAuConductorNotice, conductorNoticeWrapper);
        //作废售票员票款补款通知数据
        LambdaQueryWrapper<SwAuConductorShort> swConductorShortWrapper = new LambdaQueryWrapper<>();
        swConductorShortWrapper.eq(SwAuConductorShort::getLineCode, lineCode)
                .eq(SwAuConductorShort::getStationCode, stationCode)
                .eq(SwAuConductorShort::getConductorPersonCode, conductorJobNo)
			    .eq(SwAuConductorShort::getEquipmentNumber, deviceOperateNum)  //20240311 增加设备操作号	
                .eq(SwAuConductorShort::getCheckTime, recordTime)
                .eq(SwAuConductorShort::getDelFlag, delFlag);
        SwAuConductorShort swAuConductorShort = new SwAuConductorShort();
        swAuConductorShort.setDelFlag("1");
        swAuConductorShort.setInvalidStatus("1");
        swAuConductorShortMapper.update(swAuConductorShort, swConductorShortWrapper);
        return R.ok(true);
    }
     /**
     * 删除重复的BOM数据
     * @param id 删除除了当前BOM的其他重复数据
     * @return
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
	public R delRepeatData(int id,String flag){
		//根据审核表id查找信息
			SwAuCenterConductorAmountDifference swAuCenterConductorAmountDifference = swAuCenterConductorAmountDifferenceMapper.selectById(id);
			int incomeSettleId = swAuCenterConductorAmountDifference.getIncomeSettleId();
			String lineCode = swAuCenterConductorAmountDifference.getLineCode();
			String stationCode = swAuCenterConductorAmountDifference.getStationCode();
			String conductorJobNo = swAuCenterConductorAmountDifference.getConductorJobNo();
			String bomCode =swAuCenterConductorAmountDifference.getBomCode();
			String recordTime = "";
			try{
				recordTime = DateFormat.date_ex_str(swAuCenterConductorAmountDifference.getRecordTime());

			}catch(Exception e){
				
			}
			String deviceOperateNum = swAuCenterConductorAmountDifference.getEquipmentNumber();
			String delFlag = "0";

			//删除重复
			if("2".equals(flag)){
				 //作废BOM结算已提交主页数据
					LambdaQueryWrapper<SwStBomIncomeSettle> bomIncomeSettleWrapper = new LambdaQueryWrapper<>();
					bomIncomeSettleWrapper.eq(SwStBomIncomeSettle::getLineCode, lineCode)
							.eq(SwStBomIncomeSettle::getStationCode, stationCode)
							.eq(SwStBomIncomeSettle::getConductorJobNo, conductorJobNo)
							.eq(SwStBomIncomeSettle::getDeviceOperatorNum, deviceOperateNum)  //20240311 增加设备操作号
							//.eq(SwStBomIncomeSettle::getBomCode, bomCode)  20240911 去掉BOM编号的验证，如有BOM001， 另一个BOM001，BOM002
							.eq(SwStBomIncomeSettle::getRecordTime, recordTime)
							.ne(SwStBomIncomeSettle::getId, incomeSettleId)
							//.eq(SwStBomIncomeSettle::getId, incomeSettleId)
							.eq(SwStBomIncomeSettle::getDelFlag, delFlag);
					SwStBomIncomeSettle swStTvmIncomeSettle = new SwStBomIncomeSettle();
					swStTvmIncomeSettle.setDelFlag("1");
					swStTvmIncomeSettle.setInvalidStatus("1");
					swStBomIncomeSettleMapper.update(swStTvmIncomeSettle, bomIncomeSettleWrapper);			
					
					//根据线路、站点、收入日期、售票员工号、设备操作号、id 只保留上述两个id的值
					LambdaQueryWrapper<SwAuCenterConductorAmountDifference> conductorAmountDifferenceWrapper = new LambdaQueryWrapper<>();
					conductorAmountDifferenceWrapper.eq(SwAuCenterConductorAmountDifference::getLineCode, lineCode)
						.eq(SwAuCenterConductorAmountDifference::getStationCode, stationCode)
						.eq(SwAuCenterConductorAmountDifference::getConductorJobNo, conductorJobNo)
						.eq(SwAuCenterConductorAmountDifference::getEquipmentNumber, deviceOperateNum)  		
						.eq(SwAuCenterConductorAmountDifference::getBomCode, bomCode)
						.eq(SwAuCenterConductorAmountDifference::getRecordTime, recordTime)
						.ne(SwAuCenterConductorAmountDifference::getId, id)
					   // .eq(SwAuCenterConductorAmountDifference::getId, id)
						.eq(SwAuCenterConductorAmountDifference::getDelFlag, delFlag);
					SwAuCenterConductorAmountDifference conductorAmountDifference = new SwAuCenterConductorAmountDifference();
					conductorAmountDifference.setDelFlag("1");
					conductorAmountDifference.setInvalidStatus("1");
					swAuCenterConductorAmountDifferenceMapper.update(conductorAmountDifference, conductorAmountDifferenceWrapper);
					return R.ok(true);
			}
             //下面是删除的功能--------------------------------------
			 //作废BOM结算已提交主页数据
			LambdaQueryWrapper<SwStBomIncomeSettle> bomIncomeSettleWrapper = new LambdaQueryWrapper<>();
			bomIncomeSettleWrapper.eq(SwStBomIncomeSettle::getLineCode, lineCode)
					.eq(SwStBomIncomeSettle::getStationCode, stationCode)
					.eq(SwStBomIncomeSettle::getConductorJobNo, conductorJobNo)
					.eq(SwStBomIncomeSettle::getDeviceOperatorNum, deviceOperateNum)  //20240311 增加设备操作号
			        .eq(SwStBomIncomeSettle::getBomCode, bomCode)
					.eq(SwStBomIncomeSettle::getRecordTime, recordTime)
					.eq(SwStBomIncomeSettle::getId, incomeSettleId)
					.eq(SwStBomIncomeSettle::getDelFlag, delFlag);
			SwStBomIncomeSettle swStTvmIncomeSettle = new SwStBomIncomeSettle();
			swStTvmIncomeSettle.setDelFlag("1");
			swStTvmIncomeSettle.setInvalidStatus("1");
			swStBomIncomeSettleMapper.update(swStTvmIncomeSettle, bomIncomeSettleWrapper);			
			
			//根据线路、站点、收入日期、售票员工号、设备操作号、id 只保留上述两个id的值
			LambdaQueryWrapper<SwAuCenterConductorAmountDifference> conductorAmountDifferenceWrapper = new LambdaQueryWrapper<>();
            conductorAmountDifferenceWrapper.eq(SwAuCenterConductorAmountDifference::getLineCode, lineCode)
                .eq(SwAuCenterConductorAmountDifference::getStationCode, stationCode)
                .eq(SwAuCenterConductorAmountDifference::getConductorJobNo, conductorJobNo)
			    .eq(SwAuCenterConductorAmountDifference::getEquipmentNumber, deviceOperateNum)  		
                .eq(SwAuCenterConductorAmountDifference::getBomCode, bomCode)
                .eq(SwAuCenterConductorAmountDifference::getRecordTime, recordTime)
			    .eq(SwAuCenterConductorAmountDifference::getId, id)
                .eq(SwAuCenterConductorAmountDifference::getDelFlag, delFlag);
			SwAuCenterConductorAmountDifference conductorAmountDifference = new SwAuCenterConductorAmountDifference();
			conductorAmountDifference.setDelFlag("1");
			conductorAmountDifference.setInvalidStatus("1");
			swAuCenterConductorAmountDifferenceMapper.update(conductorAmountDifference, conductorAmountDifferenceWrapper);
		return R.ok(true);
	}
    public static BigDecimal getBigDecimal( Object value ) {
        BigDecimal ret = new BigDecimal("0.00");
        if( value != null ) {
            String data = String.valueOf(value);
            ret = new BigDecimal(data);
        }
        return ret;
    }
}
